package com.yongz.controller;


import com.alibaba.fastjson.JSONObject;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
public class Login {
    private JSONObject json_data = new JSONObject();

    @PostMapping("/dev-api/vue-admin-template/user/login")
    public Map login(@RequestBody Map map) {
        if (map.get("username") == null || map.get("password") == null || map.get("username").equals("") || map.get("password").equals("")) {
            json_data.put("code", 60204);
            json_data.put("msg", "Account and password are incorrect.");
            return json_data;
        } else if (map.get("username").equals("admin") || map.get("password").equals("123456")) {
            json_data.put("code", 20000);
            json_data.put("msg", "Login successful.");
            return json_data;
        }
        json_data.put("code", 60204);
        json_data.put("msg", "Account and password are incorrect.");
        return json_data;
    }

    @GetMapping("/register")
    public String register() {
        return "register";
    }

}
